/**
 * @file   PacketType.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2014-04-20
 * @brief  DON packet type enum and it's supporting functions.
 *
 * Copyright 2014  Djuro Drljaca (djurodrljaca@gmail.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DON_CORE_PACKET_PACKETTYPE_H
#define DON_CORE_PACKET_PACKETTYPE_H

#include <QtCore/qglobal.h>
#include <DON/Core/libdon-qt4-core_global.h>

namespace DON
{
namespace Core
{
namespace Packet
{

/**
 * @brief Enumerates all packet types
 */
enum PacketType
{
    PacketType_Invalid = -1,
    PacketType_RegistrationRequest = 0,
    PacketType_RegistrationResponse = 1,
    PacketType_GetPropertyValueRequest = 2,
    PacketType_GetPropertyValueResponse = 3,
    PacketType_SetPropertyValueRequest = 4,
    PacketType_SetPropertyValueResponse = 5,
    PacketType_ExecuteMethodRequest = 6,
    PacketType_ExecuteMethodResponse = 7,
    PacketType_Event = 8,
    PacketType_EventConfirmation = 9
};

/**
 * @brief Check if packet type is valid
 * @param packetType Packet type
 * @retval true Packet type is valid
 * @retval false Packet type is not valid
 */
LIBDONQT4CORESHARED_EXPORT bool isPacketTypeValid(const PacketType packetType);

/**
 * @brief Convert binary data to PacketType value
 * @param data Binary data
 * @param ok Error status output (true --> success, false --> error)
 * @return PacketType value
 */
LIBDONQT4CORESHARED_EXPORT PacketType fromBinaryToPacketType(const char data);

/**
 * @brief Convert PacketType value to binary data
 * @param packetType PacketType value
 * @param ok Error status output (true --> success, false --> error)
 * @return Binary data
 */
LIBDONQT4CORESHARED_EXPORT char fromPacketTypeToBinary(const PacketType packetType,
                                                       bool *ok = NULL);

}
}
}

#endif // DON_CORE_PACKET_PACKETTYPE_H
